package com.apiit.webserviceclient;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import com.apiit.webserviceclient.utils.Payment;

public class PaymentAdapter extends ArrayAdapter<Payment> {

	Context context;

	public PaymentAdapter(Context context, int resourceId, List<Payment> items) {
		super(context, resourceId, items);
		this.context = context;
	}

	/* private view holder class */
	private class ViewHolder {

		TextView date;
		TextView paymentValue;
	}
		
		   public View getView(int position, View convertView, ViewGroup parent) {
		        ViewHolder holder = null;
		        Payment rowItem = getItem(position);
		 
		        LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
		        if (convertView == null) {
		            convertView = mInflater.inflate(R.layout.activity_list, null);
		            holder = new ViewHolder();
		            
		            holder.date = (TextView) convertView.findViewById(R.id.txtDateValue);
		            holder.paymentValue = (TextView) convertView.findViewById(R.id.txtPaidValue);

		            convertView.setTag(holder);
		        } else
		            holder = (ViewHolder) convertView.getTag();
		 
		        holder.date.setText(rowItem.getDate());
		        holder.paymentValue.setText(rowItem.getPaymentValue());

		        return convertView;
		    }

	
}
